package com.topgay.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.topgay.dao.FriendListDAO;
import com.topgay.dao.MessageDAO;
import com.topgay.domain.FriendList;

@Service
public class FriendListServiceImpl implements FriendListService {

	@Autowired
	private FriendListDAO dao;
	
	@Override
	public int addFriend(FriendList friend) throws SQLException {
		//추가할 아이디의 중복 체크
		List<FriendList> listForCheck  = dao.selectFriendList(friend.getMyId());
		for(FriendList fl : listForCheck){
			if(friend.getFriendId().equals(fl.getFriendId())){
				return 100;
			}
		}
		return dao.insertFriendList(friend);
	}

	@Override
	public int removeFriend(String myid, String friendId) throws SQLException {
		return dao.deleteFriendList(myid, friendId);
	}

	@Override
	public List<FriendList> selectFriendList(String myId) throws SQLException {
		return dao.selectFriendList(myId);
	}

}
